def calculate_bmi(height, weight):
    """
    计算BMI值并返回健康分类
    
    参数:
    height: 身高(米)
    weight: 体重(千克)
    
    返回:
    tuple: (BMI值, 健康分类)
    """
    # 检查输入是否有效
    if height <= 0 or weight <= 0:
        return None, "输入必须为正数"
    
    # 计算BMI
    bmi = weight / (height ** 2)
    
    # 判断健康分类
    if bmi < 18.5:
        category = "偏瘦"
    elif 18.5 <= bmi < 24:
        category = "正常"
    elif 24 <= bmi < 28:
        category = "超重"
    elif 28 <= bmi < 30:
        category = "轻度肥胖"
    elif 30 <= bmi < 40:
        category = "中度肥胖"
    else:
        category = "重度肥胖"
    
    return round(bmi, 2), category

if __name__ == "__main__":
    try:
        height = float(input("请输入身高(米): "))
        weight = float(input("请输入体重(千克): "))
        
        bmi, category = calculate_bmi(height, weight)
        
        if bmi is not None:
            print(f"BMI值: {bmi}")
            print(f"健康分类: {category}")
        else:
            print(f"错误: {category}")
    except ValueError:
        print("输入错误: 请输入有效的数字")